<template>
    <el-dialog :title="titleDialog" :visible.sync="dialogFormVisible">
        <el-form :model="form">
            <el-form-item label="商品名称" label-width="120px">
                <el-input v-model="form.goodsName" autocomplete="off" placeholder="请输入商品名称"></el-input>
            </el-form-item>
            <el-form-item label="商品代码" label-width="120px">
                <el-input v-model="form.goodsId" autocomplete="off" placeholder="请输入商品代码"></el-input>
            </el-form-item>
            <el-form-item  label="上架时间" label-width="120px">
                <el-date-picker
                    v-model="value1"
                    :picker-options="option1"
                    type="datetime"
                    placeholder="选择日期时间">
                </el-date-picker>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="cancel">取 消</el-button>
            <el-button type="primary" @click="submit">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
const defaultform = {
    goodsName: '',
    goodsId: '',
}
export default {
    name:'GoodsModel',
    props:['dialogFormVisible','isEdit','obj'],
    data() {
      return {
        form:{
            
        },
        value1:'',
        option1:{
            disabledDate:(time)=>{
                return time.getTime() < Date.now() - 8.64e7
            }
        }
      }
    },
    computed:{
        titleDialog(){
            if(this.isEdit) {
                return '修改'
            } else {
                return '添加'
            }
        }
    },
    methods: {
        cancel(){
            this.$emit('quit',false)
        },
        submit() {
            this.$emit('submit',this.form)
        },
    },
    watch:{
        dialogFormVisible(val){
            if(this.isEdit) {//修改
                this.form = this.obj
            }else {//添加
                this.form = Object.assign({},defaultform)
            }
        }
    }
}
</script>

<style scoped>
</style>